package thinkingJava.chapter15;

public class Holder<T> {
	private T value;
	public Holder() {
	}
	public Holder(T val) {
		this.value = val;
	}
	public void set(T val) {
		this.value = val;
	}
	public T get() {
		return value;
	}
	public boolean equals(Object obj) {
		return value.equals(obj);
	}
	public static void main(String[] args) {
		Holder<Apple> ha = new Holder<Apple>(new Apple());
		Apple a = ha.get();
		ha.set(a);
		Holder<? extends Fruit> fruit = ha;
		Fruit f = fruit.get();
		a = (Apple) fruit.get();
		try {
			Orange o = (Orange)fruit.get();
		} catch (Exception e) {
			System.out.println(e);
		}
		System.out.println(fruit.equals(a));
	}
}
